// @author Maciej Chałapuk (maciej@chalapuk.pl)
// vim: ts=2 sw=2 expandtab

#include "stochastic_number.hpp"

#include <boost/test/unit_test.hpp>
#include <boost/test/test_case_template.hpp>
#include <boost/mpl/list.hpp>



BOOST_AUTO_TEST_SUITE( stochastic_number )


typedef boost::mpl::list<
    experiment::stochastic_number<sizeof(intptr_t)*8>,
    experiment::stochastic1024_t,
    experiment::stochastic2048_t,
    experiment::stochastic4096_t,
    experiment::stochastic8192_t
    > type_list;


BOOST_AUTO_TEST_CASE_TEMPLATE( cast, stoch_t, type_list ) {
  BOOST_CHECK_CLOSE(
      static_cast<double>(static_cast<stoch_t>(.5l)),
      .5l,
      stoch_t::c_epsilon*100);
}

BOOST_AUTO_TEST_CASE_TEMPLATE( multiply, stoch_t, type_list ) {
  stoch_t a = stoch_t(.5l) * stoch_t(.5l);
  BOOST_CHECK_CLOSE(
      static_cast<double>(a),
      .25l,
      160/std::log10(stoch_t::c_bitSize));
}


BOOST_AUTO_TEST_SUITE_END()

